<?php $this->placeholder('title')->set('NextdoorAngels - Ein soziales Event anlegen'); ?>
<fb:header icon="false"><fb:intl>Soziales Event anlegen</fb:intl></fb:header>
<fb:intl>Hier kannst du dein eigenes soziales Event starten und bei NextdoorAngels eintragen. Nach dem Eintragen kannst Du deine Freunde einladen und Sie so auf das Event aufmerksam machen.</fb:intl>
<fb:editor action="?do-it" labelwidth="100">
    <fb:editor-text name="title" value="<?php echo $this->escape($this->params['title']) ?>">
    	<fb:fbml-attribute name="label"><fb:intl>Titel</fb:intl></fb:fbml-attribute> 
	</fb:editor-text>
    <fb:editor-custom>
    	<fb:fbml-attribute name="label"><fb:intl>Straße</fb:intl></fb:fbml-attribute> 
        <input type="text" id="streetEditor" name="street" value="<?php echo $this->escape($this->params['street']) ?>" onchange="changePlace();"/>
    </fb:editor-custom>
    <fb:editor-custom>
    	<fb:fbml-attribute name="label"><fb:intl>Stadt</fb:intl></fb:fbml-attribute> 
        <input type="text" id="cityEditor" name="city" value="<?php echo $this->escape($this->params['city']) ?>" onchange="changePlace();"/>
		<img id="map" width="300" height="200" style="border:0;margin:4px 0 0 0;"/>
    </fb:editor-custom>
	<fb:editor-date <?php if(isset($this->date)) { echo 'value="'.$this->date.'"'; } ?> >
    	<fb:fbml-attribute name="label"><fb:intl>Datum</fb:intl></fb:fbml-attribute> 
	</fb:editor-date>	
	<fb:editor-time <?php if(isset($this->date)) { echo 'value="'.$this->date.'"'; } ?> name="time">
    	<fb:fbml-attribute name="label"><fb:intl>Uhrzeit</fb:intl></fb:fbml-attribute> 
	</fb:editor-time> 
	<fb:editor-textarea name="description" rows="10">
    	<fb:fbml-attribute name="label"><fb:intl>Beschreibung</fb:intl></fb:fbml-attribute> 
		 <?php echo $this->escape($this->params['description']) ?>
	</fb:editor-textarea>
    <fb:editor-buttonset>
        <fb:editor-button>
	    	<fb:fbml-attribute name="value"><fb:intl>Event anlegen</fb:intl></fb:fbml-attribute> 
       	</fb:editor-button>
		<fb:editor-cancel href="<?php echo $this->canvasUrl ?>"/>
    </fb:editor-buttonset>
</fb:editor>
<script>
<?php if(!$this->permission) { echo "Facebook.showPermissionDialog('create_event', function(permissions) { if(permissions==='') { document.setLocation('".$this->canvasUrl."'); } });"; } ?>
        function changePlace(){
			var street = document.getElementById('streetEditor').getValue();
			var city = document.getElementById('cityEditor').getValue();
			if (street.length > 0 && city.length > 0) {
				var place = escape(street + ", " + city);
				var map = document.getElementById('map');
    	        map.setSrc("http://maps.google.com/maps/api/staticmap?center=" + place + "&zoom=14&size=300x200&maptype=roadmap&markers=color:blue|label:S|" + place + "&sensor=false&key=ABQIAAAAquIIHMFUJg94ExRueMgLfBQIu6Cqdu4lKKxoe7OOJi78eqEEHxRsyWCmPNoQeMzdw--XVrPd4alMGA");
			}
        }
</script>
